<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <title>API管理 - ApiServ</title>
    {{template "head.html" .}}
</head>
<body id="as-api-list">
    <div class="container-fluid">
        <div class="container">
            <div class="jumbotron as-mgt-50px">
                <h1>API管理</h1>
                <p>在这里，您可以通过新建、删除、编辑等操作管理您的API <!--，以及通过标签对您的API进行分组--></p>
                <p class="help-block" style="font-size: 16px;">您当前的接口列表浏览链接：<a href="{{urlfor "BaseController.Apis" ":user" $.LoginUser.Username}}">{{$.ApiDomain}}{{urlfor "BaseController.Apis" ":user" $.LoginUser.Username}}</a>，您可以把该链接发给您的朋友。</p>
                <p>
                    <a href="{{urlfor "IndexController.Index"}}" class="btn btn-primary"> <i class="fa fa-home"></i> 首页</a>
                    <a href="{{urlfor "UserController.ApiCreate"}}" class="btn btn-primary"> <i class="fa fa-plus"></i> 新建接口</a>
                    {{/*<a href="#" class="btn btn-primary" target="_blank"> <i class="fa fa-question"></i> 使用帮助</a>*/}}
                    <a href="{{urlfor "BaseController.Logout"}}" class="btn btn-primary"> <i class="fa fa-sign-out"></i> 退出登录</a>
                </p>
            </div>

            <div class="row">
                {{/*<div class="col-xs-12 as-mgt-50px text-right">*/}}
                    {{/*<ul class="pagination">*/}}
                        {{/*<li><a href="#">&laquo;</a></li>*/}}
                        {{/*<li class="active"><a href="#">1</a></li>*/}}
                        {{/*<li class="disabled"><a href="#">2</a></li>*/}}
                        {{/*<li><a href="#">3</a></li>*/}}
                        {{/*<li><a href="#">4</a></li>*/}}
                        {{/*<li><a href="#">5</a></li>*/}}
                        {{/*<li><a href="#">&raquo;</a></li>*/}}
                    {{/*</ul>*/}}
                {{/*</div>*/}}
                <div class="col-xs-12">


                    <div class="panel-group" id="accordion">
                        {{range $idx,$val:=$.Apis}}
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <h4 class="panel-title">
                                        <a data-toggle="collapse" data-parent="#accordion" href="#collapse{{.Id}}">{{.Title}}</a>
                                        <span class="pull-right">
                                        <a href="{{urlfor "UserController.ApiCreate"}}?id={{.Id}}"> <i class="fa fa-pencil"></i> 编辑</a>  <span> | </span>
                                        <a href="{{urlfor "UserController.ApiDel"}}?id={{.Id}}" class="ajax-get"> <i class="fa fa-remove"></i> 删除</a>
                                    </span>
                                    </h4>
                                </div>
                                <div id="collapse{{.Id}}" class="panel-collapse collapse {{if eq $idx 0}}in{{end}}">
                                    <div class="panel-body">
                                        <ul>
                                            <li>
                                                <div>请求API</div>
                                                <div class="help-block">{{.Api}}</div>
                                            </li>
                                            <li>
                                                <div>请求URL</div>
                                                <div class="help-block">{{$.ApiDomain}}/api/{{$.LoginUser.Username}}/{{TrimLeft .Api " /"}}</div>
                                            </li>
                                            <li>
                                                <div>请求方法</div>
                                                <div class="help-block">
                                                {{range (Split .Methods ",")}}
                                                    <span class="label label-success">{{.}}</span>
                                                {{end}}
                                                </div>
                                            </li>
                                            <li>
                                                <div>请求参数</div>
                                                <div class="help-block">
                                                    <div class="table-responsive">
                                                        <table class="table">
                                                            <thead>
                                                            <tr>
                                                                <th>参数名</th>
                                                                <th>参数类型</th>
                                                                <th>参数说明</th>
                                                            </tr>
                                                            </thead>
                                                            <tbody>
                                                            {{range (HandleParams .Params)}}
                                                            <tr>
                                                                <td>{{.ParamsName}}</td>
                                                                <td>{{.ParamsType}}</td>
                                                                <td>{{.ParamsState}}</td>
                                                            </tr>
                                                            {{end}}
                                                            </tbody>
                                                        </table>
                                                    </div>
                                                </div>
                                            </li>
                                            <li>
                                                <div>成功时JSON响应</div>
                                                <div class="help-block">
                                                    <div class="help-block">格式化数据 <i class="fa fa-hand-o-down"></i> </div>
                                                    <pre class="json-renderer"></pre>
                                                    <div class="help-block">原数据 <i class="fa fa-hand-o-down"></i> </div>
                                                    <textarea class="form-control" rows="2">{{.JsonSucc}}</textarea>

                                                </div>
                                            </li>
                                            <li>
                                                <div>失败时JSON响应</div>
                                                <div class="help-block">
                                                    <div class="help-block">格式化数据 <i class="fa fa-hand-o-down"></i> </div>
                                                    <pre class="json-renderer"></pre>
                                                    <div class="help-block">原数据 <i class="fa fa-hand-o-down"></i> </div>
                                                    <textarea class="form-control" rows="2">{{.JsonErr}}</textarea>
                                                </div>
                                            </li>
                                            <li>
                                                <div>响应字段</div>
                                                <div class="help-block">
                                                    <div class="table-responsive">
                                                        <table class="table">
                                                            <thead>
                                                            <tr>
                                                                <th>响应字段</th>
                                                                <th>字段说明</th>
                                                            </tr>
                                                            </thead>
                                                            <tbody>
                                                            {{range (HandleResp .Resp)}}
                                                            <tr>
                                                                <td>{{.ResponseField}}</td>
                                                                <td>{{.ResponseState}}</td>
                                                            </tr>
                                                            {{end}}
                                                            </tbody>
                                                        </table>
                                                    </div>
                                                </div>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        {{end}}
                    </div>
                </div>
            </div>
        </div>
  </div>
    {{template "foot.html" .}}
</body>
</html>
